import * as constants from './constants'
import {fromJS} from 'immutable'
const defaultState = fromJS({
    focus: false,
    mouseIn: false,
    searchValue: '',
    searchKeys: []
})
const reducer = (state = defaultState, action)=> {
    switch (action.type) {
        case constants.FOCUS:
            return state.set('focus',true);
        case constants.BLUR:
            return state.set('focus',false);
        case constants.SEARCH_VALUE_CHANGE:
            return state.set('searchValue',action.value);
        case constants.FETCH_SEARCH_KEYS:
            return state.set('searchKeys',action.value)
        case constants.MOUSE_ENTER:
            return state.set('mouseIn',true)
        case constants.MOUSE_LEAVE:
            return state.merge({
                'mouseIn':false
            })
        case constants.CHANGE_SEARCH_KEYS:
            return state.merge({
                'searchKeys': action.value
            })
        default:
            return state
    }
}
export default reducer